package com.cai.baseapplication.mvp.main.home

import android.content.Intent
import android.os.Bundle
import com.cai.baseapplication.net.TestService
import com.cai.baselibrary.mvp.presenter.IPresenter
import com.cai.baselibrary.net.callback.JsonCallback
import com.cai.baselibrary.net.response.SimpleResponse
import com.lzy.okgo.model.Response

class HomePresenter (view : HomeContract.HomeView):IPresenter<HomeContract.HomeView> (view),HomeContract.HomePresenter{


    override fun onCreateView(arguments: Bundle?) {
        super.onCreateView(arguments)
        register("17771436337","123456")
    }


    override fun register(telephone: String, password: String) {
        TestService.register(telephone,password,object : JsonCallback<SimpleResponse>(){
            override fun onSuccess(response: Response<SimpleResponse>) {
                mView.get()?.apply {
                    onSuccess(response.body().msg)
                }
            }

            override fun onError(response: Response<SimpleResponse>?) {
                super.onError(response)
            }

        })
    }

}